import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    count:0
  },
  mutations: {
    updateCount(state,num){
      state.count=num;
    }
  },
  actions: {
      updateCountSync(store,data){
          store.commit('updateCount',data+1);
      }
  },
  getters:{
    getCount(state){
      return state.count+1;
    }
  }
})
/*
this.$store.commit('updateCount',data);
this.$store.state.count;
this.$store.getters.getCount;
this.$store.dispatch('updateCountSync',data)

...mapActions(['updateCountSync'])
 ...mapState({
    count:'count'
}),
...mapGetters({
    getCount:'getCount'
})
* */
